{{- if .Values.extendedMonitoring.imageAvailability.exporterEnabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: image-availability-exporter
  namespace: d8-monitoring
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: d8:extended-monitoring:image-availability-exporter
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
rules:
- apiGroups: [""]
  resources:
  - secrets
  verbs:
  - list
  - watch
  - get
- apiGroups: [""]
  resources:
    - namespaces
  verbs:
    - list
    - watch
- apiGroups: [""]
  resources:
  - serviceaccounts
  - namespaces
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - extensions
  - apps
  resources:
  - deployments
  - daemonsets
  - statefulsets
  verbs:
  - list
  - watch
  - get
- apiGroups:
  - batch
  resources:
  - cronjobs
  verbs:
  - list
  - watch
  - get
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: d8:extended-monitoring:image-availability-exporter
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
subjects:
- kind: ServiceAccount
  name: image-availability-exporter
  namespace: d8-monitoring
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: d8:extended-monitoring:image-availability-exporter
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: d8:extended-monitoring:image-availability-exporter:rbac-proxy
  {{- include "helm_lib_module_labels" (list .) | nindent 2 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: d8:rbac-proxy
subjects:
- kind: ServiceAccount
  name: image-availability-exporter
  namespace: d8-monitoring
{{- end }}
